package com.yidu.BusinessManagement.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * TA交易结算持久层接口
 * @Version 1.0
 * @Author zsc
 * @Date 2022/12/16 10:01
 */
@Mapper
public interface TaSettlementMapper {

    /**
     * 根据ta编号修改交易类型
     * @param arg0 交易类型
     * @param arg1 ta编号
     * @return
     */
    @Update ("update ta set dealState=#{arg0} where taId=#{arg1}")
    public int updateTaSettlement(int arg0,String arg1);

    /**
     * 拿到资金调拨的最大ID
     * @return
     */
    @Select("SELECT fundsAllotId FROM fundsAllot ORDER BY fundsAllotId  DESC LIMIT 1")
    public String SelectMaxfundsAllotId();

    /**
     * 根据现金账户编号得到现金账户名称
     * @param cashId 现金账户编号
     * @return
     */
    @Select ("select accountName from cash where cashId=#{cashId}")
    public String SelectAccountName(String cashId);

    /**
     * 根据ta编号修改交易类型
     * @param arg0 交易类型
     * @param arg1 ta编号
     * @return
     */
    @Update ("update ta set dealState=#{arg0} where taId=#{arg1}")
    public int updateTaSettlementTwo(int arg0,String arg1);

    /**
     * 根据业务编号删除资金调拨
     * @param taId
     * @return
     */
    @Delete (" delete from fundsAllot where businessId=#{taId}")
    public int deleteFundsAllot(String taId);

    /**
     * 查询资金调拨的数据
     * @return
     */
    @Select ("select count(*) from fundsAllot")
    public int SeletctFundsAllotCount();
}
